import axios from 'axios';
import {loginreq, req, reqjson} from './axiosFun';

// 登录接口
export const login = (params) => {
  return loginreq("post", "/api/login", params)
};
// 获取用户菜单
export const menu = (params) => {
  return axios.get("/api/menu?&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};
// 退出接口
export const loginout = () => {
  return axios.delete("/api/login?&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};

/**
 * 收派件订单
 **/
// 收派件订单-获取用户列表
export const userList = (params) => {
  return reqjson("post", "/makeOrder/addOrder", params)
};
export const dicList = (params) => {
  return req("get", "/tips/getTipsNameByIds/"+params,{})
};
// 字典查询
export const tipsList = (params) => {
  return reqjson("post", "/tips/getTips", params)
};
// 收派件订单-保存（添加编辑）
//export const userSave = (params) => { return req("post", "/makeOrder/addOrder", params) };
// 用户管理-用户待处理任务
export const userProcess = (params) => {
  return req("get", "/makeOrder/getProcessingOrderMatchResult/" + params, {})
};
// 收派件订单-删除用户
export const userDelete = (params) => {
  return axios.delete("/api/ReceivingOrders/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};
// 收派件订单-重置密码
export const userPwd = (params) => {
  return req("post", "/api/ReceivingOrders/pwd", params)
};
// 收派件订单-修改状态
export const userLock = (params) => {
  return axios.get("/api/ReceivingOrders/lock?userId=" + params.userId + "&lock=" + params.lock + "&token=" + localStorage.getItem('logintoken'))
};


// 用户管理-用户下线
export const userExpireToken = (params) => {
  return req("get", "/api/User/expireToken/" + params, {})
};
// 用户管理-刷新缓存
export const userFlashCache = (params) => {
  return req("get", "/api/User/flashCache/" + params, {})
};

/**
 * 非收派订单
 **/
// 非收派订单-获取菜单Module/list
export const ModuleList = () => {
  return req("post", "/makeOrder/addOrder")
};
// 非收派订单-根据菜单获取数据
export const ModuleGet = (params) => {
  return axios.get("/api/AtypicalOrders/get/" + params + "?token=" + localStorage.getItem('logintoken'))
};
// 非收派订单-获取父级菜单Module/nodes
export const ModuleNodes = (params) => {
  return req("post", "/api/AtypicalOrders/nodes", params)
};
// 非收派订单-修改菜单
export const ModuleSave = (params) => {
  return req("post", "/api/AtypicalOrders/save", params)
};
// 非收派订单-删除菜单
export const ModuleDelete = (params) => {
  return axios.delete("/api/AtypicalOrders/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};

/**
 * 引擎配置
 **/
// 引擎配置-获取角色列表
export const roleList = () => {
  return req("get", "/engine/getAll")
};
// 引擎配置-保存（添加编辑）
export const roleSave = (params) => {
  return reqjson("put", "/engine/updateEngineConfigs", params)
};
// 引擎配置-删除角色
export const roleDelete = (params) => {
  return axios.delete("/api/Role/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};
// 引擎配置-菜单权限（获取）
export const RoleRightTree = (params) => {
  return axios.get("/api/RoleRight/tree/" + params + "?token=" + localStorage.getItem('logintoken'))
};
// 引擎配置-菜单权限（保存）
export const RoleRightSave = (params) => {
  return req("post", "/api/RoleRight/save", params)
};


/**
 * 匹配结果
 **/
// 匹配结果-获取权限列表
export const permissionList = (params) => {
  return req("post", "/api/MatchingResult/list", params)
};
// 匹配结果-保存权限
export const ermissionSave = (params) => {
  return req("post", "/api/MatchingResult/save", params)
};
// 匹配结果-删除权限
export const ermissionDelete = (params) => {
  return axios.delete("/api/MatchingResult/delete?ids=" + params + "&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};
// 匹配结果-获取权限
export const roleDropDown = () => {
  return axios.get("/api/EngineSettings/dropDown/all?&token=" + localStorage.getItem('logintoken')).then(res => res.data)
};
// 匹配结果-配置权限
export const RolePermission = (params) => {
  return req("post", "/api/RolePermission/save", params)
};
